﻿using Microsoft.AspNetCore.Mvc;
using Restful_Api.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Restful_Api.Controllers
{

    [Route("api")]
    [ApiController]
    /// <summary>
    /// 用于获取/api路由的时候返回一些 公共的url
    /// </summary>
    public class RootController : ControllerBase
    {
        [HttpGet(Name = nameof(GetRoot))]
        public IActionResult GetRoot()
        {
            var links = new List<LinkDto>();
            links.Add(new LinkDto(
                Url.Link(nameof(GetRoot), new { }),
                "self", "Get"
                ));
            links.Add(new LinkDto(
              Url.Link(nameof(CompaniesController.GetCompanies), new { }),
              "Companies", "Get"
              ));
            links.Add(new LinkDto(
          Url.Link(nameof(CompaniesController.CreateCompany), new { }),
          "CreateCompany", "Post"
          ));
            return Ok(links);
        }
    }
}
